<%-- 
    Document   : ClientList
    Created on : 12/Jan/2010, 22:42:58
    Author     : Marco
--%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>${requestScope['title']} - ${requestScope['action']}</title>
        <style type="text/css">
            body { font-family: Verdana, sans-serif; font-size:80%}
            table {
                border-color:black;
                border-style:solid;
                border-width:thin;
                padding:0;
                margin:0;
            }
            tr.l1 {
                background:lightblue;
                padding:0;
                margin:0;
            }
            tr.l2 {
                padding:0;
                margin:0;
            }
        </style>
    </head>
    <body>
        <h1>${requestScope['title']} - ${requestScope['action']}</h1>
        <form action="?" method="POST">
            <c:choose>
                <c:when test="${!empty requestScope['collection']}">
                    <input type="hidden" name="clientId" value="" />
                    <table>
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Nome</th>
                                <th>NIF/NIPC</th>
                                <th>CP</th>
                                <td><input type="button" value="Novo cliente" onclick="this.form.action='?action=new'; this.form.submit();"/></td>
                            </tr>
                        </thead>
                        <tbody>
                            <c:forEach var="client" items="${requestScope['collection']}" varStatus="loop">
                                <tr class="${loop.index % 2 == 0 ? 'l1' : 'l2'}">
                                    <td>${client.id}</td>
                                    <td>${client.name}</td>
                                    <td>${client.nif}</td>
                                    <td>${client.town}</td>
                                    <td><input type="button" value="Ver" onclick="this.form.action='?action=detail'; this.form.clientId.value=${client.id}; this.form.submit();"/></td>
                                </tr>
                            </c:forEach>
                        </tbody>
                    </table>
                </c:when>
                <c:otherwise>
                    <div><span>Não existem clientes.
                            <input type="button" value="Novo cliente" onclick="this.form.action='?action=new'; this.form.submit();"/></span></div>
                        </c:otherwise>
                    </c:choose>
            <br/>
            <input type="button" value="Voltar" onclick="this.form.action='${requestScope['contextPath']}'; this.form.submit();"/>
        </form>
    </body>
</html>
